home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Control del ratón / CheckerWithChildrenAndFocus / CheckerChildWithFocus.cs next >
Encoding:
Text File  |  2001-01-15  |  789 b   |  30 lines

  1. //----------------------------------------------------
  2. // CheckerChildWithFocus.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class CheckerChildWithFocus: CheckerChild
  10. {
  11.      protected override void OnGotFocus(EventArgs ea)
  12.      {
  13.           Invalidate();
  14.      }
  15.      protected override void OnLostFocus(EventArgs ea)
  16.      {
  17.           Invalidate();
  18.      }
  19.      protected override void OnPaint(PaintEventArgs pea)
  20.      {
  21.           base.OnPaint(pea);
  22.  
  23.           if (Focused)
  24.           {
  25.                Graphics grfx = pea.Graphics;
  26.                grfx.DrawRectangle(new Pen(ForeColor, 5), ClientRectangle);
  27.           }
  28.      }
  29. }
  30.